package com.bwie.product.init;

import com.bwie.product.esMapper.ProductEsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * 初始化创建索引
 *
 * @author <a href="mailto:2943147140@qq.com">刘洋朔</a>
 * @version 1.0
 * @description: 初始化创建索引
 * @date 2025/9/9 19:04
 */
@Component("productInit")
public class productInit {

    @Autowired
    private ProductEsMapper productEsMapper;
    /**
     * 初始化ES索引
     */
    @PostConstruct
    private void productEsInit(){
        //检查索引
        Boolean hasKey = productEsMapper.existsIndex("product");
        if (!hasKey) {
            productEsMapper.createIndex("product");
        }
    }
}
